package zd.vrp.operator;

import zd.vrp.global.GlobalInformation;
import zd.vrp.global.Route;
import zd.vrp.test.Test;
import zd.vrp.utils.TestUtils;



public class OptOperation {
	//contains several opt methods including 2-opt, 3-opt, ect.

	public Route twoOpt(Route route1, Route route2, int loc1, int loc2) {
		Route childRoute = new Route();
		
		for(int i=1;i<=loc1;i++){
			childRoute.insertCityIntoRoute(route1.getCityList().get(i).clone(), childRoute.getLastCityIndex());
		}
		for(int i=loc2+1;i<=route2.getRouteSize()-2;i++){
			childRoute.insertCityIntoRoute(route2.getCityList().get(i).clone(),childRoute.getLastCityIndex());

		}
		
		return childRoute;
	}
    
	public static void main(String[] args) {
		Test.testSolomonInsertion();
		System.out.println(GlobalInformation.routeList.size());
		OptOperation oop = new OptOperation();
		TestUtils.showRoute(GlobalInformation.routeList.get(1));
		TestUtils.showRoute(GlobalInformation.routeList.get(2));
		Route childRoute = oop.twoOpt(GlobalInformation.routeList.get(1), GlobalInformation.routeList.get(2), 2, 3);
		TestUtils.showRoute(childRoute);
	}
}
